package com.example.systemwork.controller;


import com.example.systemwork.common.controller.LogicController;
import com.example.systemwork.dao.BusinessDao;
import com.example.systemwork.entity.Business;
import com.example.systemwork.entity.Item;
import com.example.systemwork.entity.Shop;
import com.example.systemwork.entity.ShopItem;
import com.example.systemwork.service.BusinessService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "商家实体的控制器")
@RestController
@RequestMapping("/business")
public class BusinessController extends LogicController<BusinessService, BusinessDao, Business, Long> {
    public BusinessController ( @Autowired BusinessService ss ) {
        super ( ss );
    }

    @ApiOperation("测试用方法")
    @GetMapping("/test")
    public String test () {
        return "OK";
    }

    @ApiOperation("创建门店")
    @GetMapping("/createShop")
    public Shop createShop ( @ApiParam("商家ID") Long bus_id,@ApiParam("门店名称") String shopName ) {
        return getService ( ).createShop ( bus_id,shopName );
    }

    @ApiOperation("上架商品")
    @GetMapping("/shelfGoods")
    public ShopItem shelfGoods (@ApiParam("门店ID") Long shopId,
                                 @ApiParam("商品ID") Long itemId ) {
        return getService ( ).shelfGoods (shopId , itemId );
    }

    @ApiOperation("新建商品")
    @GetMapping("/newItem")
    public Item newItem (@ApiParam("商家ID") Long bus_id,@ApiParam("商品名称") String itemName, @ApiParam("商品价格") Double price ) {
        return getService ( ).newItem (bus_id,itemName, price);
    }
}
